home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / VOXRAY.ZIP / IDBSP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-02  |  5.3 KB  |  204 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include <stdlib.h>
  4. #include "cmdlib.h"
  5.  
  6. #ifndef __IDBSP__
  7. #define __IDBSP__
  8.  
  9. #include "storage.h"
  10.  
  11. #include <math.h>
  12. #include <limits.h>
  13. #include <float.h>
  14. /*#include "cmdlib.h" */
  15. #include "doomdata.h"
  16. #include "wadfile.h"
  17. /* #include "doomdata.h" */
  18.  
  19. /*
  20. #define SHORT(x)        NXSwapLittleShortToHost((short)x)
  21. #define LONG(x)         NXSwapLittleLongToHost((long)x)
  22. */
  23.  
  24. /*
  25. #define SHORT(x) LittleShort((short)x)
  26. #define LONG(x)  LittleLong((long)x)
  27. */
  28. /*
  29. #define SHORT(x) BigShort((short)x)
  30. #define LONG(x) BigLong((long)x)
  31. */
  32. /*
  33. #define SHORT(x) (short)(x)
  34. #define LONG(x) (long)(x)
  35. */
  36.  
  37. #define PI   3.141592657
  38.  
  39. #define         MAXVERTEX               8192
  40. #define         MAXTOUCHSECS    16
  41. #define         MAXSECTORS              2048
  42. #define         MAXSUBSECTORS   2048
  43.  
  44. typedef struct
  45.         {
  46.         float x;
  47.         float y;
  48.         } NXPoint;
  49.  
  50. typedef struct
  51.         {
  52.         float width;
  53.         float height;
  54.         } NXSize;
  55.  
  56. typedef struct
  57.         {
  58.         NXPoint origin;
  59.         NXSize size;
  60.         } NXRect;
  61.  
  62. /*
  63. ===============================================================================
  64.  
  65.                                                         map file types
  66.  
  67. ===============================================================================
  68. */
  69.  
  70. typedef struct
  71. {
  72.         int                     floorheight, ceilingheight;
  73.         char            floorflat[9], ceilingflat[9];
  74.         int                     lightlevel;
  75.         int                     special, tag;
  76. } sectordef_t;
  77.  
  78. typedef struct
  79. {
  80.         int                     firstrow;
  81.         int                     firstcollumn;
  82.         char            toptexture[9];
  83.         char            bottomtexture[9];
  84.         char            midtexture[9];
  85.         sectordef_t     sectordef;                      /* on the viewers side */
  86.         int                     sector;                         /* only used when saving doom map */
  87. } worldside_t;
  88.  
  89. typedef struct
  90. {
  91.         NXPoint         p1, p2;
  92.         int                     special, tag;
  93.         int                     flags;
  94.         worldside_t     side[2];
  95. } worldline_t;
  96.  
  97. #define ML_BLOCKMOVE    1
  98. #define ML_TWOSIDED             4       /* backside will not be present at all if not two sided */
  99.  
  100. typedef struct
  101. {
  102.         NXPoint         origin;
  103.         int                     angle;
  104.         int                     type;
  105.         int                     options;
  106.         int                     area;
  107. } worldthing_t;
  108.  
  109. /*
  110. ===============================================================================
  111.  
  112.                                                         internal types
  113.  
  114. ===============================================================================
  115. */
  116.  
  117. typedef struct
  118. {
  119.         NXPoint pt;
  120.         float   dx,dy;
  121. }divline_t;
  122.  
  123. typedef struct bspstruct_s
  124. {
  125. /*      id                                              lines_i;                // if non NULL, the node is */
  126.         STORAGE *lines_i;
  127.         STORAGE *cutbox_i;
  128.         divline_t                               divline;                /* terminal and has no children */
  129.         float                                   bbox[4];
  130.         struct  bspstruct_s             *side[2];
  131. } bspnode_t;
  132.  
  133.  
  134. typedef struct
  135. {
  136.         NXPoint         p1, p2;
  137.         int                     linedef, side, offset;
  138.         boolean         grouped;                                /* internal error check */
  139. } line_t;
  140.  
  141.  
  142. /*
  143. ===============================================================================
  144.  
  145.                                                                 idbsp
  146.  
  147. ===============================================================================
  148. */
  149.  
  150. /*
  151. ===============================================================================
  152.  
  153.                                                                 doomload
  154.  
  155. ===============================================================================
  156. */
  157.  
  158. extern  STORAGE *linestore_i;
  159.  
  160. /*
  161. ===============================================================================
  162.  
  163.                                                                 drawing
  164.  
  165. ===============================================================================
  166. */
  167.  
  168. extern  float   scale;
  169. extern  NXRect          worldbounds;
  170.  
  171. /*
  172. ===============================================================================
  173.  
  174.                                                                 buildbsp
  175.  
  176. ===============================================================================
  177. */
  178.  
  179. extern  int             cuts;                   /* number of new lines generated by BSP process */
  180. extern  bspnode_t       *startnode;
  181.  
  182. void BuildBSP (void);
  183. void    DivlineFromWorldline (divline_t *d, line_t *w);
  184. int     PointOnSide (NXPoint *p, divline_t *l);
  185. void ExecuteSplit(STORAGE *lines_i, line_t *spliton, STORAGE *frontlist_i,
  186. STORAGE *backlist_i);
  187. void SplitCutBoxes(STORAGE *cutbox_i, line_t *spliton, STORAGE *frontlist_i,
  188. STORAGE *backlist_i);
  189.  
  190.  
  191. /*
  192. ===============================================================================
  193.  
  194.                                                         savebsp
  195.  
  196. ===============================================================================
  197. */
  198.  
  199. void Make_Line_List();
  200. void Generate_BSP();
  201. void ConvBSP (void);
  202.  
  203. #endif
  204.